package tawai;

import java.util.Random;


/**
 * Class models Non-Player-Controlled player<br>
 * Supposed to have AI, but uses {@link Random} for now<br>
 * Implements {@link IterativelyActive} because NPC has to "think" iteratively
 * 
 * @author Alex
 */
public class NPC extends Player implements IterativelyActive{

    /**
     * Random responsible for outstanding AI
     */
    private static Random rand = new Random(System.currentTimeMillis() % Integer.MAX_VALUE);

    /**
     * Iterative action lies in "thinking" and giving commands to tank<br>
     * Incredible Artificial Intelligence lies somewhere out here
     *
     * @see IterativelyActive
     */
    public void performIterativeAction() {

        if(!alive)
            TawaiMIDlet.getMain().removeSceneObject(this);

        switch(rand.nextInt() % 13) {
            case 0:
                tank.setDir(0);
                break;
            case 1:
                tank.setDir(90);
                break;
            case 2:
                tank.setDir(180);
                break;
            case 3:
                tank.setDir(270);
                break;
            case 4:
            case 5:
            case 6:
                tank.startMoving();
                break;
            case 7:
            case 8:
            case 9:
                tank.stopMoving();
                break;
            case 10:
            case 11:
            case 12:
                tank.shoot();
                break;
        }

    }

}
